﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Lavanderia.Entities;

namespace Lavanderia.Repository
{
    public class MenuRepository:MasterRepository,IMenuRepository
    {

        //metodo para mostrar las pestañas generales del menu
        public List<MENU> GetAllFromMenu()
        {
            var query = from c in context.MENUs
                        where c.Tag == 1000 || c.Tag == 2000 || c.Tag == 2050 || c.Tag == 3000 || c.Tag == 3050 || c.Tag == 4000 || c.Tag == 5000
                        select c;
            return query.ToList();
        }


        //metodo para avanzar a las sub pestañas del menu general
        public List<MENU> GetAllFromMenuByTag(int tag)
        {
            if (tag == 1000)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1005 || c.Tag == 1010 || c.Tag == 1015 || c.Tag == 1020 || c.Tag == 1025 || c.Tag == 1030 || c.Tag == 1035 || c.Tag == 1040 || c.Tag == 1045
                            select c;
                return query.ToList();
            }
            else if (tag == 2000)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2005 || c.Tag == 2010 || c.Tag == 2015
                            select c;
                return query.ToList();
            }
            else if (tag == 2050)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2055 || c.Tag == 2060 || c.Tag == 2065
                            select c;
                return query.ToList();
            }
            else if (tag == 3000)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3005 || c.Tag == 3010 || c.Tag == 3020
                            select c;
                return query.ToList();
            }
            else if (tag == 3050)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3055 || c.Tag == 3060 || c.Tag == 3065
                            select c;
                return query.ToList();
            }
            else if (tag == 4000)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4005 || c.Tag == 4015 || c.Tag == 4020
                            select c;
                return query.ToList();
            }
            else if (tag == 5000)
            {
                var query = from c in context.MENUs
                            where c.Tag == 5005 || c.Tag == 5010 || c.Tag == 5015 || c.Tag == 5020
                            select c;
                return query.ToList();
            }
            else
            {
                var query = from c in context.MENUs
                            where c.Tag == null
                            select c;
                return query.ToList();
            }
        }

        
        //metodo para avanzar a los detalles de cada pestaña del menu
        public List<MENU> GetAllFromMenuByMantenimientoByTag(int tag)
        {
            if (tag == 1005)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1006 || c.Tag == 1007 || c.Tag == 1008 || c.Tag == 1009
                            select c;
                return query.ToList();
            }
            else if (tag == 1010)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1011 || c.Tag == 1012 || c.Tag == 1013 || c.Tag == 1014
                            select c;
                return query.ToList();
            }
            else if (tag == 1015)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1016 || c.Tag == 1017 || c.Tag == 1018 || c.Tag == 1019
                            select c;
                return query.ToList();
            }
            else if (tag == 1020)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1021 || c.Tag == 1022 || c.Tag == 1023 || c.Tag == 1024
                            select c;
                return query.ToList();
            }
            else if (tag == 1025)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1026 || c.Tag == 1027 || c.Tag == 1028 || c.Tag == 1029
                            select c;
                return query.ToList();
            }
            else if (tag == 1030)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1031 || c.Tag == 1032 || c.Tag == 1033 || c.Tag == 1034
                            select c;
                return query.ToList();
            }
            else if (tag == 1035)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1036 || c.Tag == 1037 || c.Tag == 1038 || c.Tag == 1039
                            select c;
                return query.ToList();
            }
            else if (tag == 1040)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1041 || c.Tag == 1042 || c.Tag == 1043 || c.Tag == 1044
                            select c;
                return query.ToList();
            }
            else if (tag == 1045)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1046 || c.Tag == 1047 || c.Tag == 1048 || c.Tag == 1049
                            select c;
                return query.ToList();
            }
            else if (tag == 2005)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2006 || c.Tag == 2007 || c.Tag == 2008 || c.Tag == 2009
                            select c;
                return query.ToList();
            }
            else if (tag == 2010)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2011 || c.Tag == 2012 || c.Tag == 2013 || c.Tag == 2014
                            select c;
                return query.ToList();
            }
            else if (tag == 2015)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2016 || c.Tag == 2017 || c.Tag == 2018 || c.Tag == 2019
                            select c;
                return query.ToList();
            }
            else if (tag == 2055)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2056
                            select c;
                return query.ToList();
            }
            else if (tag == 2060)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2061
                            select c;
                return query.ToList();
            }
            else if (tag == 2065)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2066 || c.Tag == 2067 || c.Tag == 2068
                            select c;
                return query.ToList();
            }
            else if (tag == 3005)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3006 || c.Tag == 3007 || c.Tag == 3008 || c.Tag == 3009
                            select c;
                return query.ToList();
            }
            else if (tag == 3010)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3011 || c.Tag == 3012 || c.Tag == 3013 || c.Tag == 3014 || c.Tag == 3015
                            select c;
                return query.ToList();
            }
            else if (tag == 3020)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3021 || c.Tag == 3022 || c.Tag == 3023 || c.Tag == 3024 || c.Tag == 3025 || c.Tag == 3026 || c.Tag == 3027 || c.Tag == 3028 || c.Tag==3029 || c.Tag == 3030
                            select c;
                return query.ToList();
            }
            else if (tag == 3055)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3056 || c.Tag == 3057 || c.Tag == 3058 || c.Tag == 3059
                            select c;
                return query.ToList();
            }
            else if (tag == 3060)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3061 || c.Tag == 3062 || c.Tag == 3063 || c.Tag == 3064
                            select c;
                return query.ToList();
            }
            else if (tag == 3065)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3066 || c.Tag == 3067 || c.Tag == 3068 || c.Tag == 3069 || c.Tag == 3070 || c.Tag == 3071 || c.Tag == 3072 || c.Tag == 3073
                            select c;
                return query.ToList();
            }
            else if (tag == 4005)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4006 || c.Tag == 4007 || c.Tag == 4008 || c.Tag == 4009 || c.Tag == 4010
                            select c;
                return query.ToList();
            }
            else if (tag == 4015)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4016 || c.Tag == 4017 || c.Tag == 4018 || c.Tag == 4019
                            select c;
                return query.ToList();
            }
            else if (tag == 4020)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4021 || c.Tag == 4022 || c.Tag == 4023 || c.Tag == 4024
                            select c;
                return query.ToList();
            }
            else if (tag == 5005)
            {
                var query = from c in context.MENUs
                            where c.Tag == 5006 || c.Tag == 5007
                            select c;
                return query.ToList();
            }
            else if (tag == 5010)
            {
                var query = from c in context.MENUs
                            where c.Tag == 5011 || c.Tag == 5012
                            select c;
                return query.ToList();
            }
            else
            {
                var query = from c in context.MENUs
                            where c.Tag == null
                            select c;
                return query.ToList();
            }
        }


        //metodo para retroceder en la buskeda del menu
        public List<MENU> GetAllFromMenuByMantenimeintoByTagByReturn(int tag)
        {
            if (tag == 1006 || tag == 1007 || tag == 1008 || tag == 1009 || tag == 1011 || tag == 1012 || tag == 1013 || tag == 1014 ||
                tag == 1016 || tag == 1017 || tag == 1018 || tag == 1019 || tag == 1021 || tag == 1022 || tag == 1023 || tag == 1024 ||
                tag == 1026 || tag == 1027 || tag == 1028 || tag == 1029 || tag == 1031 || tag == 1032 || tag == 1033 || tag == 1034 ||
                tag == 1036 || tag == 1037 || tag == 1038 || tag == 1039 || tag == 1041 || tag == 1042 || tag == 1043 || tag == 1044 ||
                tag == 1046 || tag == 1047 || tag == 1048 || tag == 1049)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1005 || c.Tag == 1010 || c.Tag == 1015 || c.Tag == 1020 || c.Tag == 1025 ||
                            c.Tag == 1030 || c.Tag == 1035 || c.Tag == 1040 || c.Tag == 1045
                            select c;
                return query.ToList();
            }
            else if (tag == 2006 || tag == 2007 || tag == 2008 || tag == 2009 || tag == 2011 || tag == 2012 || tag == 2013 || tag == 2014 ||
                tag == 2016 || tag == 2017 || tag == 2018 || tag == 2019)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2005 || c.Tag == 2010 || c.Tag == 2015
                            select c;
                return query.ToList();
            }
            else if (tag == 2056 || tag == 2061 || tag == 2066 || tag == 2067 || tag == 2068)
            {
                var query = from c in context.MENUs
                            where c.Tag == 2055 || c.Tag == 2060 || c.Tag == 2065
                            select c;
                return query.ToList();
            }
            else if (tag == 3006 || tag == 3007 || tag == 3008 || tag == 3009  || tag == 3011 || tag == 3012 || tag == 3013 || tag == 3014 || tag == 3015 ||
                tag == 3021 || tag == 3022 || tag == 3023 || tag == 3024 || tag == 3025 || tag == 3026 || tag == 3027 || tag == 3028 || tag == 3029 || tag == 3030)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3005 || c.Tag == 3010 || c.Tag == 3020
                            select c;
                return query.ToList();
            }
            else if (tag == 3056 || tag == 3057 || tag == 3058 || tag == 3059 || tag == 3061 || tag == 3062 || tag == 3063 || tag == 3064 || tag == 3066 || tag == 3067 || tag == 3068 ||
                tag == 3069 || tag == 3070 || tag == 3071 || tag == 3072 || tag == 3073)
            {
                var query = from c in context.MENUs
                            where c.Tag == 3055 || c.Tag == 3060 || c.Tag == 3065
                            select c;
                return query.ToList();
            }
            else if (tag == 4006 || tag == 4007 || tag == 4008 || tag == 4009 || tag == 4010 || tag == 4016 || tag == 4017 || tag == 4018 || tag == 4019 ||
                tag == 4021 || tag == 4022 || tag == 4023 || tag == 4024)
            {
                var query = from c in context.MENUs
                            where c.Tag == 4005 || c.Tag == 4015 || c.Tag == 4020
                            select c;
                return query.ToList();
            }
            else if (tag == 5006 || tag == 5007 || tag == 5011 || tag == 5012)
            {
                var query = from c in context.MENUs
                            where c.Tag == 5005 || c.Tag == 5010 || c.Tag == 5015 || c.Tag == 5020
                            select c;
                return query.ToList();
            }
            else if (tag >= 1005 || tag <= 1050 || tag >= 2005 || tag <= 2020 || tag >= 2050 || tag <= 2080 || tag >= 3005 || tag <= 3040 || tag >= 3050 || tag <= 3080 || tag >= 4005 || tag <= 4030 || 
                tag >= 5005 || tag <= 5030)
            {
                var query = from c in context.MENUs
                            where c.Tag == 1000 || c.Tag == 2000 || c.Tag == 2050 || c.Tag == 3000 || c.Tag == 3050 || c.Tag == 4000 || c.Tag == 5000
                            select c;
                return query.ToList();
            }
            else
            {
                var query = from c in context.MENUs
                            where c.Tag == null
                            select c;
                return query.ToList();
            }
        }
    }
}
